home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / misc / emu / arosdev.lha / AROS / workbench / c / path.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  2KB  |  105 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: path.c,v 1.7 1997/01/27 00:22:37 ldp Exp $
  4.     $Log: path.c,v $
  5.     Revision 1.7  1997/01/27 00:22:37  ldp
  6.     Include proto instead of clib
  7.  
  8.     Revision 1.6  1996/10/04 17:09:44  digulla
  9.     More readable way to access arguments
  10.  
  11.     Revision 1.5  1996/10/04 14:35:41  digulla
  12.     Make "path x: ADD" work as expected. "path x:" works now, too
  13.  
  14.     Revision 1.4  1996/09/17 16:43:01  digulla
  15.     Use general startup code
  16.  
  17.     Revision 1.3  1996/09/13 17:52:11  digulla
  18.     Use IPTR
  19.  
  20.     Revision 1.2  1996/08/01 17:40:45  digulla
  21.     Added standard header for all files
  22.  
  23.     Desc:
  24.     Lang:
  25. */
  26. #include <exec/memory.h>
  27. #include <proto/exec.h>
  28. #include <dos/dosextens.h>
  29. #include <proto/dos.h>
  30.  
  31. UBYTE Buffer[4096];
  32.  
  33. int main (int argc, char ** argv)
  34. {
  35.     struct RDArgs *rda;
  36.     IPTR args[6]={ 0, 0, 1, 0, 0, 0 };
  37. #define ARG_Path    ((STRPTR *)args[0])
  38. #define ARG_Add     ((BOOL)args[1])
  39. #define ARG_Show    ((BOOL)args[2])
  40. #define ARG_Reset    ((BOOL)args[3])
  41. #define ARG_Remove    ((BOOL)args[4])
  42. #define ARG_Quiet    ((BOOL)args[5])
  43.  
  44.     IPTR parg[1];
  45.  
  46.     rda=ReadArgs("PATH/M,ADD/S,SHOW/S,RESET/S,REMOVE/S,QUIET/S",args,NULL);
  47.     if(rda!=NULL)
  48.     {
  49.     STRPTR *names=ARG_Path;
  50.     BPTR *cur, *next;
  51.     struct CommandLineInterface *cli;
  52.     cli=Cli();
  53.     if (*names)
  54.     {
  55.         /* Search last entry */
  56.         cur=&cli->cli_CommandDir;
  57.         while (cur[0])
  58.         cur=(BPTR *)BADDR(cur[0]);
  59.  
  60.         while(*names!=NULL)
  61.         {
  62.         next=(BPTR *)AllocVec(2*sizeof(BPTR),MEMF_ANY);
  63.         next[1]=Lock(*names,SHARED_LOCK);
  64.         if(!next[1])
  65.         {
  66.             FreeVec(next);
  67.             break;
  68.         }
  69.         cur[0]=MKBADDR(next);
  70.         cur=next;
  71.         if(!ARG_Quiet)
  72.             VPrintf("%s added.\n",(ULONG *)names);
  73.         names++;
  74.         }
  75.         cur[0] = 0;
  76.     }
  77.     else
  78.     {
  79.         BPTR l;
  80.  
  81.         l = Lock ("", SHARED_LOCK);
  82.         if (l)
  83.         {
  84.         NameFromLock (l, Buffer, sizeof (Buffer));
  85.         parg[0] = (IPTR) Buffer;
  86.         VPrintf ("Current Directory: %s\n", parg);
  87.         UnLock (l);
  88.         }
  89.  
  90.         cur=(BPTR *)BADDR(cli->cli_CommandDir);
  91.         while(cur)
  92.         {
  93.         NameFromLock (cur[1], Buffer, sizeof (Buffer));
  94.         parg[0] = (IPTR) Buffer;
  95.         VPrintf ("%s\n", parg);
  96.         cur=(BPTR *)BADDR(cur[0]);
  97.         }
  98.         VPrintf ("C:\n", NULL);
  99.     }
  100.  
  101.     FreeArgs(rda);
  102.     }
  103.     return 0;
  104. }
  105.